import axiosInstance from '@/utils/http'

export interface Menu {
  id: number
  name: string
  createTime: Date
  updateTime: Date
}

export function create(data: Menu): Promise<R<Menu>> {
  return axiosInstance.post<R<Menu>>('/menu', { data })
}
export function getById(id: number): Promise<R<Menu>> {
  return axiosInstance.get<R<Menu>>(`/menu/${id}`)
}

export function updateById(data: Menu): Promise<R<Menu>> {
  return axiosInstance.put<R<Menu>>(`/menu`, { data })
}

export function deleteById(id: number): Promise<R<Menu>> {
  return axiosInstance.delete<R<Menu>>(`/menu/${id}`)
}

export function getList(data: Menu): Promise<R<Menu[]>> {
  return axiosInstance.post<R<Menu[]>>('/menu/list', { data })
}
export function count(data: Menu): Promise<R<number>> {
  return axiosInstance.post<R<number>>('/menu/count', { data })
}

export function page(data: Menu, page: number, size: number): Promise<R<Menu[]>> {
  return axiosInstance.post<R<Menu[]>>(`/menu/${page}/${size}/page`, { data })
}
